<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
  
    <script>
        var cookie=document.cookie;//获取cookie
        if(cookie){//有cookie的时候处理
            var dataList=cookie.split('; ')
            console.log(dataList)

            var data={}
            for(var i=0;i<dataList.length;i++){
                var item=dataList[i]
                console.log(item)
                var arr=item.split('=')
                console.log(arr)
                var key=arr[0]
                var val=arr[1]
                // data.key=val
                data[key]=val
            }
        }
        console.log(data)
    </script>
</body>
</html>